home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Profi Tools / DiskSpeed / src / DiskSpeedCPU.asm < prev    next >
Assembly Source File  |  1998-07-30  |  8KB  |  213 lines

  1. *
  2. *                          DiskSpeed v4.0
  3. *                                by
  4. *                           Michael Sinz
  5. *
  6. *             Copyright (c) 1989 by MKSoft Development
  7. *
  8. *                      MKSoft Development
  9. *                      163 Appledore Drive
  10. *                      Downingtown, PA 19335
  11. *
  12. * Yes, this is yet another disk speed testing program, but with a few
  13. * differences.  It was designed to give the most accurate results of the
  14. * true disk performance in the system.  For this reason many of
  15. * DiskSpeed's results may look either lower or higher than current disk
  16. * performance tests.
  17. *
  18. ******************************************************************************
  19. *                                                                            *
  20. *      Reading legal mush can turn your brain into guacamole!                *
  21. *                                                                            *
  22. *              So here is some of that legal mush:                           *
  23. *                                                                            *
  24. * Permission is hereby granted to distribute this program's source           *
  25. * executable, and documentation for non-commercial purposes, so long as the  *
  26. * copyright notices are not removed from the sources, executable or          *
  27. * documentation.  This program may not be distributed for a profit without   *
  28. * the express written consent of the author Michael Sinz.                    *
  29. *                                                                            *
  30. * This program is not in the public domain.                                  *
  31. *                                                                            *
  32. * Fred Fish is expressly granted permission to distribute this program's     *
  33. * source and executable as part of the "Fred Fish freely redistributable     *
  34. * Amiga software library."                                                   *
  35. *                                                                            *
  36. * Permission is expressly granted for this program and it's source to be     *
  37. * distributed as part of the Amicus Amiga software disks, and the            *
  38. * First Amiga User Group's Hot Mix disks.                                    *
  39. *                                                                            *
  40. ******************************************************************************
  41. *
  42.     INCLUDE    "exec/types.i"
  43.     INCLUDE    "exec/tasks.i"
  44.     INCLUDE    "exec/lists.i"
  45.     INCLUDE    "exec/libraries.i"
  46. *
  47. ******************************************************************************
  48. *
  49. * This section of code is used to test CPU availability.  It was important
  50. * that it be in assembly as it would otherwise be unpredictable.
  51. *
  52.     SECTION    "CPU_TEST",CODE
  53. *
  54.     xdef    _CPU_Use_Base
  55.     xdef    _CPU_State_Flag
  56.     xdef    _CPU_Count_Low
  57.     xdef    _CPU_Count_High
  58.     xdef    @Init_CPU_Available
  59.     xdef    @Free_CPU_Available
  60.     xdef    @CPU_Calibrate
  61. *
  62.     xref    _LVOAddTask
  63.     xref    _LVORemTask
  64.     xref    _AbsExecBase
  65. *
  66. ******************************************************************************
  67. *
  68. * This init routine does all sorts of work to install the task...
  69. *
  70. @Init_CPU_Available:
  71.         lea    _CPU_State_Flag(pc),a0    ; Point at state flag...
  72.         moveq.l    #0,d0            ; Get a NULL...
  73.         move.l    d0,(a0)+        ; Clear state flag...
  74.         move.l    d0,(a0)+        ; Clear low count...
  75.         move.l    d0,(a0)+        ; Clear high count...
  76.         move.l    (a0),d0        ; Check if we are already running...
  77.         bne.s    Task_Set    ; If so, we don't start again...
  78. *
  79.         lea    _CPU_Use_Base(pc),a1    ; Point at use flag...
  80.         tst.l    (a1)            ; Check if we are to run...
  81.         beq.s    Task_Set        ; If not, we just return...
  82. *
  83. * The task is not running...  First, clear the task structure...
  84. *
  85.         lea    Task_Struct(pc),a1    ; Point at task structure...
  86.         moveq.l    #TC_SIZE-1,d1        ; We want to clear the task
  87. Clear_TC:    move.b    d0,(a1)+        ; Clear a byte...
  88.         dbra    d1,Clear_TC        ; Clear all of the task...
  89. *
  90. * Ok, now set up the task structure and get going...
  91. *
  92.         movem.l    a2/a3/a6,-(sp)        ; Save these...
  93.         lea    CPU_Available(pc),a2    ; Initial PC...
  94.         move.l    d0,a3            ; NULL final PC...
  95.         lea    Task_Struct(pc),a1    ; Point at task structure...
  96.         lea    TC_MEMENTRY(a1),a0    ; Point at the TC_MEMENTRY
  97.         NEWLIST    a0            ; list header; initialize it.
  98.         lea    Stack_Lower(pc),a0    ; Point at low stack...
  99.         move.l    a0,TC_SPLOWER(a1)    ; Set the task structure...
  100.         lea    Stack_Upper(pc),a0    ; Task upper stack...
  101.         move.l    a0,TC_SPUPPER(a1)    ; Set the task structure...
  102.         move.l    a0,TC_SPREG(a1)        ; Starting point...
  103.         move.b    #NT_TASK,LN_TYPE(a1)    ; It is a task...
  104.         move.b    #-127,LN_PRI(a1)    ; Set to minimal priority...
  105.         move.l    _AbsExecBase,a6        ; Get ExecBase...
  106.         jsr    _LVOAddTask(a6)        ; Add the task...
  107. *
  108. *******************************************************************************
  109. *
  110. * Check to see if we are running in V37 ROM or better.  If so,
  111. * we want to use the result of the AddTask() call...  Otherwise
  112. * we just want the task structure address...
  113. *
  114.         cmp.w    #36,LIB_VERSION(a6)    ; Check if exec is > V36
  115.         bcc.s    TooNew            ; If greater than V36, skip...
  116.         lea    Task_Struct(pc),a1    ; Get task structure...
  117.         move.l    a1,d0            ; Put it into d0...
  118. TooNew:
  119. *
  120. *******************************************************************************
  121. *
  122.         movem.l    (sp)+,a2/a3/a6        ; Restore...
  123. Set_Task:    lea    CPU_Task(pc),a0        ; Point at storage...
  124.         move.l    d0,(a0)            ; Save the pointer...
  125. *
  126. * D0 is now either a task pointer or NULL since it did not get added...
  127. *
  128. Task_Set:    rts
  129. *
  130. ******************************************************************************
  131. *
  132. * This routine will kill the task...
  133. *
  134. @Free_CPU_Available:
  135.         move.l    CPU_Task(pc),d0        ; Check if we have a task...
  136.         beq.s    Task_Set        ; If not, just return...
  137.         move.l    d0,a1            ; Point at task...
  138.         move.l    a6,-(sp)        ; Save a6...
  139.         move.l    _AbsExecBase,a6        ; Get ExecBase...
  140.         jsr    _LVORemTask(a6)        ; Remove the task...
  141.         move.l    (sp)+,a6        ; Restore a6...
  142.         moveq.l    #0,d0            ; Clear d0...
  143.         bra.s    Set_Task        ; Set the task pointer...
  144. *
  145. ******************************************************************************
  146. *
  147. * This routine will set up and then count the number of times through the loop
  148. * below.  Since CPUs may become very fast, the counters are 64-bits.  This
  149. * should last for a long time!  (Currently, it would most likely never need
  150. * more than the first 32-bit word...)
  151. *
  152. CPU_Available:    lea    _CPU_State_Flag(pc),a0    ; Set up some pointers
  153.         lea    _CPU_Count_Low(pc),a1
  154.         lea    _CPU_Count_High(pc),a2
  155. *
  156. * Here, we check if the state flag is zero.  Once it is, we drop
  157. * down into the next routine...
  158. *
  159. CheckState:    tst.l    (a0)        ; Check if we got the green-light.
  160.         bne.s    CheckState    ; If not, try again...
  161. *
  162. * Now, we count the low order counter.  If it does not wrap, we loop back...
  163. *
  164.         addq.l    #1,(a1)        ; Add 1 to low order counter...
  165.         bne.s    CheckState    ; If we did not wrap, we go back...
  166. *
  167. * Since the low order counter just wrapped, we now count the high order...
  168. * Note that we assume that there would never be an overflow in the high order
  169. * counter word.
  170. *
  171.         addq.l    #1,(a2)        ; Add 1 to high order counter...
  172.         bra.s    CheckState    ; Loop back...
  173. *
  174. ******************************************************************************
  175. *
  176. * This routine is used to calibrate the CPU available number...
  177. *
  178. @CPU_Calibrate:    lea    _CPU_Count_Low(pc),a0    ; Get up pointer...
  179. *
  180. * Now, we want to make the same instructions so that timing will
  181. * be the same...
  182. *
  183. Calibrate:    tst.l    (a0)        ; Check if we are done...
  184.         beq.s    CalibrateDone    ; If so, exit...
  185. *
  186. * Now, count backwards until we get to 0...
  187. *
  188.         subq.l    #1,(a0)        ; Subtract 1 from low order counter...
  189.         bne.s    Calibrate    ; Loop back for some more...
  190. *
  191. * We get here when done with the calibration loop...
  192. *
  193. CalibrateDone:    rts
  194. *
  195. ******************************************************************************
  196. *
  197. _CPU_Use_Base:        dc.l    0    ; Set to TRUE in order to use CPU...
  198. _CPU_State_Flag:    dc.l    0    ; Used to control this routine...
  199. _CPU_Count_Low:        dc.l    0    ; The low-order word for CPU count
  200. _CPU_Count_High:    dc.l    0    ; The high-order word for CPU count
  201. CPU_Task:        dc.l    0    ; The task pointer...
  202. *
  203. ******************************************************************************
  204. *
  205. Stack_Lower:        ds.l    80    ; 80 long-words of stack for task
  206. Stack_Upper:        dc.l    0
  207. Task_Struct:        ds.b    TC_SIZE    ; The task structure...
  208. Task_Name:        dc.b    'MKSoft DiskSpeed CPU Test',0
  209. *
  210. ******************************************************************************
  211. *
  212.         END
  213.